Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
async-mqtt
Advanced tools
Promise wrapper over MQTT.js
IMPORTANT: Make sure you handle rejections from returned promises because they won't crash the process
The API is the same as MQTT.js, except the following functions now return promises instead of taking callbacks
const MQTT = require("async-mqtt");
const client = MQTT.connect("tcp://somehost.com:1883");
// When passing async functions as event listeners, make sure to have a try catch block
const doStuff = async () => {
console.log("Starting");
try {
await client.publish("wow/so/cool", "It works!");
// This line doesn't run until the server responds to the publish
await client.end();
// This line doesn't run until the client has disconnected without error
console.log("Done");
} catch (e){
// Do something about it!
console.log(e.stack);
process.exit();
}
}
client.on("connect", doStuff);
Alternately you can skip the event listeners and get a promise.
const MQTT = require("async-mqtt");
run()
async function run() {
const client = await MQTT.connectAsync("tcp://somehost.com:1883")
console.log("Starting");
try {
await client.publish("wow/so/cool", "It works!");
// This line doesn't run until the server responds to the publish
await client.end();
// This line doesn't run until the client has disconnected without error
console.log("Done");
} catch (e){
// Do something about it!
console.log(e.stack);
process.exit();
}
}
const { AsyncClient } = require("async-mqtt");
const client = getRegularMQTTClientFromSomewhere();
const asyncClient = new AsyncClient(client);
asyncClient.publish("foo/bar", "baz").then(() => {
console.log("We async now");
return asyncClient.end();
});
FAQs
Promise wrapper over MQTT.js
The npm package async-mqtt receives a total of 28,919 weekly downloads. As such, async-mqtt popularity was classified as popular.
We found that async-mqtt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.